#ifndef FKUSER_H
#define FKUSER_H

#include <QStringList>
#include <QHash>
#include <QVariant>

#include "FKObject.h"

class FKClient;

class FKOBJECTSSHARED_EXPORT FK_OBJECT(FKUser,FKObject)
    Q_OBJECT
    Q_PROPERTY(QString cn READ userName WRITE setName)
public:
//    FKUser(FKRoom* room=0, qint32 objectID=-1);
//    ~FKUser();
    void setClient(FKClient* client){_client=client;}
    void manageEvent(FKEvent* event);
    void manageAction(FKEvent* action);
    QString userName() const;
    bool isInIgnore(FKUser* u) const;

    static void setNameReestr(QString clientType);
    static QStringList nameReestr();
    static bool isInReestr(QString userName);
    static bool addToReestr(QString userName);
    static bool removeFromReestr(QString userName);

    static FKUser* catchUser(QString userName);

//    void setConnected();
    void setDisconnected();
signals:
    void roomChosen(FKRoom* room);
    void privateMessageRecieved(QString message);
    void commandMessageRecieved(QString message);
    void chatErrorMessageRecieved(QString message);
private:
    void enterRoom(FKRoom* room);
    void enterRoom_A(qint32 roomID);
    bool setName(QString userName);
    QString parseMessage(QString &message, QString &reciever);
    void publicMessage(QString message);
    void privateMessage(QString message, QString reciever);
    void chatErrorMessage(QString message);
//    QStringList initActionList();
//    QStringList initEventList();
    QString _userName;
    static QHash<QString,FKUser*> _users;
    static QStringList _nameReestr;
    static QString _clientType;
//    FKRoom* _room;

    void A_enterRoom(FKEvent* event);
    void E_enterRoom(FKEvent* event);
    void A_createRoom(FKEvent* event);
    void A_exitRoom(FKEvent *event);
    void E_exitRoom(FKEvent *event);
    void A_message(FKEvent* event);
    void E_privateMessage(FKEvent* event);
    void E_commandMessage(FKEvent* event);
    void E_chatErrorMessage(FKEvent* event);
    void A_setName(FKEvent* event);

    FKClient* _client;

    FK_NO_SERVANT
    FK_NO_CUSTOM_VALUES
};

#endif // FKUSER_H
